package cn.linstudy.mq;

import cn.linstudy.web.controller.OrderInfoController;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * @Description 回补预库存消费者
 * @Author XiaoLin
 * @Date 2021/5/21 16:58
 */
@Component
@Slf4j
@RocketMQMessageListener(
    consumerGroup = "MQChangeLocalListener",
    topic = MQConstant.CANCEL_SECKILL_OVER_SIGE_TOPIC,
    messageModel = MessageModel.BROADCASTING // 指定模式为广播模式
)
public class MQChangeLocalListener implements RocketMQListener<Long > {

  @Override
  public void onMessage(Long seckillId) {
    log.info("开始进行回补预库存");
    OrderInfoController.local_flag.put(seckillId,false);
  }
}
